using System.Collections.Generic;
using FastMapper.Configuration;
using System.Linq;
using FastMapper.Core;

namespace FastMapper
{
    public class FastMapperConfigurator : IMapperConfigurator
    {
        private readonly IPropertyMatchFormatter _propertyMatchFormatter = new PropertyMatchFormatter();
        private readonly ISet<ITypeMapConfigurator> _typeMapConfigurators = new HashSet<ITypeMapConfigurator>();


        public IMapperEngine Compile(string filePath = null, bool useIfExists = false)
        {
            throw new System.NotImplementedException();
        }

        public void Generate(string folderPath)
        {
            throw new System.NotImplementedException();
        }

        public IEnumerable<string> Prefixes
        {
            get { return _propertyMatchFormatter.Prefixes; }
        }
        public IEnumerable<string> PostFixes
        {
            get { return _propertyMatchFormatter.PostFixes; }
        }
        public IEnumerable<IPropertyMatchCondition> PropertyMatchConditions
        {
            get { return _propertyMatchFormatter.PropertyMatchConditions; }
        }

        public void AddPrefixe(string prefixe)
        {
            _propertyMatchFormatter.AddPrefixe(prefixe);
        }

        public void AddPrefixes(IEnumerable<string> prefixes)
        {
            _propertyMatchFormatter.AddPrefixes(prefixes);
        }

        public void AddPostFixes(IEnumerable<string> postfixes)
        {
            _propertyMatchFormatter.AddPostFixes(postfixes);
        }

        public void AddPostFixe(string postfixe)
        {
            _propertyMatchFormatter.AddPostFixe(postfixe);
        }

        public void AddCustomPropertyMatchCondition(IPropertyMatchCondition propertyMatchCondition)
        {
            _propertyMatchFormatter.AddCustomPropertyMatchCondition(propertyMatchCondition);
        }

        public ITypeMapConfigurator<TSource, TDestination> CreateMap<TSource, TDestination>()
        {
            var typeMapConfig = new TypeMapConfigurator<TSource, TDestination>();
            if (_typeMapConfigurators.Add(typeMapConfig))
                return typeMapConfig;
            return _typeMapConfigurators.FirstOrDefault(typeMapConfig.Equals) as ITypeMapConfigurator<TSource, TDestination>;
        }

        public IMapperGenerator Configure(IList<ITypeMapConfigurator> typeMapConfigurators = null)
        {
            throw new System.NotImplementedException();
        }
    }
}